package edu.uwosh.cs342.group1.storage;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;

import android.os.Parcel;
import android.os.Parcelable;

@Root
public class MultipleChoice extends Question implements Parcelable {

	@Attribute
	private String answer1;
	@Attribute
	private String answer2;
	@Attribute
	private String answer3;
	@Attribute
	private String answer4;
	
	public MultipleChoice() {
		super();
	}
	
	public MultipleChoice(@Attribute(name="title")String title,@Attribute(name="key") String key, String answer1, String answer2, String answer3,String answer4){
		this.title = title;
		this.key = key;
		this.answer1 = answer1;
		this.answer2 = answer2;
		this.answer3 = answer3;
		this.answer4 = answer4;
	}
	public MultipleChoice(Parcel parc) {
		super(parc);
		this.answer1 = parc.readString();
		this.answer2 = parc.readString();
		this.answer3 = parc.readString();
		this.answer4 = parc.readString();
		System.out.println("There");
		// TODO Auto-generated constructor stub
	}
	/**
	 * Gets the answer by the index (1-4)
	 * @param answerIndex
	 * @return
	 */
	public String getAnswer(int answerIndex) {
		switch (answerIndex) {
			case 0:
				return this.answer1;
			case 1:
				return this.answer2;
			case 2:
				return this.answer3;
			case 3:
				return this.answer4;
			default:
				return "";
		}
	}
	
	public String getTitle() {
		return this.title;
	}
	
	public boolean isTrueFalse() {
		return false;
	}
	
	public boolean isShortAnswer() {
		return false;
	}
	
	public boolean isMultipleChoice() {
		return true;
	}
	public static final Parcelable.Creator<MultipleChoice> CREATOR
    = new Parcelable.Creator<MultipleChoice>() {
		public MultipleChoice createFromParcel(Parcel in) {
			return new MultipleChoice(in);
		}

		public MultipleChoice[] newArray(int size) {
			return new MultipleChoice[size];
		}
	};
	
	/**
	 * Sets the answer by the index (1 - 4)
	 * @param answerIndex
	 * @param answer
	 */
	public void setAnswer(int answerIndex, String answer) {
		switch(answerIndex) {
			case 0:
				this.answer1 = answer;
				break;
			case 1:
				this.answer2 = answer;
				break;
			case 2:
				this.answer3 = answer;
				break;
			case 3:
				this.answer4 = answer;
				break;	
		}
	}

	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		super.writeToParcel(dest, flags);
		dest.writeString(answer1);
		dest.writeString(answer2);
		dest.writeString(answer3);
		dest.writeString(answer4);
		
		System.out.println("Here");
		
	}
}
